package vn.com.vega.music.view.adapter;

import vn.com.vega.chacha.R;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class MainMenuAdapter extends BaseAdapter {
	private final int[] menuNames = { 
			R.string.main_menu_song_online,
			R.string.main_menu_song_personal, R.string.main_menu_search,
			/*R.string.main_menu_song_had_download,*/
			R.string.main_menu_account_info,
			R.string.main_menu_exit_application};

	private final int[] menuThumbs = { 
			R.drawable.ic_main_menu_song_online,
			R.drawable.ic_main_menu_personal_music,
			R.drawable.ic_main_menu_search,
			/*R.drawable.ic_main_menu_song_had_download,*/
			R.drawable.ic_main_menu_info,
			R.drawable.ic_exit_menu_main};

	private LayoutInflater inflater;

	public MainMenuAdapter(Context ctx) {
		inflater = (LayoutInflater) ctx
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return menuNames.length;
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		MainMenuHolder holder;
		if (convertView == null) {
			convertView = inflater.inflate(R.layout.main_menu_item, null);
			holder = new MainMenuHolder();
			holder.menuName = (TextView) convertView
					.findViewById(R.id.tv_menu_name);
			convertView.setTag(holder);
		} else {
			holder = (MainMenuHolder) convertView.getTag();
		}

		holder.menuName.setText(menuNames[position]);
		holder.menuName.setCompoundDrawablesWithIntrinsicBounds(
				menuThumbs[position], 0, 0, 0);
		return convertView;
	}

	static class MainMenuHolder {
		TextView menuName;
	}

}
